<!-- 移除 Google Fonts 动态加载：兼容中国大陆用户，避免访问不可达域名 -->

<!-- main styles -->
{{ $styles := slice }}
{{ $stylesLazy := slice }}

{{ range site.Params.plugins.css }}
  {{ if findRE "^http" .link }}
    <link
      crossorigin="anonymous"
      media="all"
      rel="stylesheet"
      href="{{ .link | relURL }}"
      {{ .attributes | safeHTMLAttr }} />
  {{ else }}
    {{ if not .lazy }}
      {{ $styles = $styles | append (resources.Get .link) }}
    {{ else }}
      {{ $stylesLazy = $stylesLazy | append (resources.Get .link) }}
    {{ end }}
  {{ end }}
{{ end }}

{{ $mainCSS := resources.Get "css/main.css" }}
{{ $tailwindOpts := dict "inlineImports" true }}
{{ $tailwindCSS := $mainCSS | css.TailwindCSS $tailwindOpts }}

{{ $styles = $styles | append $tailwindCSS }}
{{ $styles = $styles | resources.Concat "css/style.css" }}

{{ $stylesLazy = $stylesLazy | resources.Concat "css/style-lazy.css" }}

{{ if hugo.IsProduction }}
  {{ $styles = $styles | minify | fingerprint }}
  {{ $stylesLazy = $stylesLazy | minify | fingerprint }}
{{ end }}


<!-- link main style -->
<link
  href="{{ $styles.RelPermalink }}"
  integrity="{{ $styles.Data.Integrity }}"
  rel="stylesheet" />

<link
  defer
  async
  rel="stylesheet"
  href="{{ $stylesLazy.RelPermalink }}"
  integrity="{{ $stylesLazy.Data.Integrity }}"
  media="print"
  onload="this.media='all'; this.onload=null;" />
